package com.aisi.backend.domain;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: shenjianZ
 * @Date: 2024/4/30 下午10:49
 * @Description:
 */


@Getter
@ToString
public enum RestCode{

    SUCCESS(200,"操作成功"),
    FAILURE(400,"操作失败"),
    USERNAME_OR_PASSWORD_ERROR(402,"用户名或密码错误"),
    NO_LOGIN(401,"用户未登录"),
    UNAUTHORIZED(403,"未授权"),
    TOKEN_EXPIRE(403, "token已过期"),
    TOKEN_EMPTY(403, "token不能为空"),
    TOKEN_INVALID(403, "token非法"),
    SYSTEM_ERROR(500,"系统错误，请联系管理员" ),
    DATA_NOT_FOUND(404,"数据不存在"),
    CODE_BAD_REQUEST(400,"上传的图片为空" ),
    IMAGE_UPLOAD_FAILED(400,"上传图片失败" );

    final Integer code;
    final String message;


    RestCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    @JsonValue
    public Map<String, Object> toJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("message", message);
        map.put("code", code);
        return map;
    }
}